#!/usr/bin/env python
# encoding: utf-8


"""
@file: others.py
@time: 2017/3/8 下午6:39
"""
# 其他的一些问题
from mathsolver.functions.base import *
from operator import itemgetter


# 圆内接四边形，已知各边长求面积
# Input parmaer1: BaseEqs
class YuanNeiJieSiBianXingMianJi(BaseFunction):
    def solver(self, *args):
        self.label.add('圆内接四边形，已知各边长求面积')
        side_values = args[0].sympify()
        side_names = map(itemgetter(0), side_values)  # 边的名字
        s1, s2, s3, s4 = side_names
        s = sympify('s')
        area = sqrt((s - s1) * (s - s2) * (s - s3) * (s - s4))
        s_v = sympify('1/2') * (s1 + s2 + s3 + s4)
        self.steps.append(['由题意可知S = ', new_latex(area) + '其中' + BaseEq([s, s_v]).printing()])
        area_value = area.subs(s, s_v).subs(side_values)
        self.steps.append(['求得S=', new_latex(area_value)])
        self.output.append(BaseNumber(area_value))
        return self


if __name__ == '__main__':
    pass
